<?php
/**
 * User: ppjun378
 * Data: 2019/01/02
 * Time: 11:00
 */
namespace App\Api\Controllers;

use App\Service\PicturesService;
use Illuminate\Http\Request;

class PicturesController extends BaseController
{
    /**
     * 添加/更新
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @author ppjun378 <ppjun378@foxmail.com>
     */
    public function store(Request $request)
    {
        $result = PicturesService::store($request);
        if ($result) {
            // return $this->success();
            return $result;
        } else {
            return $this->error();
        }
    }

    /**
     * 获取数据
     * @param Request $request
     * @return mixed
     * @author ppjun378 <ppjun378@foxmail.com>
     */
    public function getinfo(Request $request)
    {
        $result = PicturesService::dataList($request);
        return $result;
    }

    /**
     * 获取数据
     * @param Request $request
     * @return mixed
     * @author ppjun378 <ppjun378@foxmail.com>
     */
    public function getinfo_appendix(Request $request)
    {
        $result = PicturesService::dataList($request, 2);
        return $result;
    }

    /**
     * 添加/更新(附件)
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @author ppjun378 <ppjun378@foxmail.com>
     */
    public function store_appendix(Request $request)
    {
        $result = PicturesService::store($request, 2);
        if ($result) {
            // return $this->success();
            return $result;
        } else {
            return $this->error();
        }
    }

    /**
     * 附件上传页面
     * @author ppjun378 <ppjun378@foxmail.com>
     */
    public function upload_appendix(Request $request)
    {
        $resume_id = $request->input('resume_id', '');
        $token = $request->input('token', '');
        $view = view('appendix/upload', compact('resume_id', 'token'));
        return $view;
    }

}
